package inet.sms.process;
import java.util.*;

import inet.util.*;
import inet.util.Queue;
import inet.pdu.*;


public class TestProcessor extends Processor {
	 private Logger logger =null;
	 private final String info1="XS truc tiep:\nBan se nhan duoc ket qua XSMB lan quay toi theo tung giai khi co. Thong tin chi tiet goi 1900561588\n Chuc may man";
	 private String requestDate=null;
	 private String tomorowDate;
	 private String yesterdayDate;
	
	
	 private boolean isStart;
	 private Scanner scanner;
	 public TestProcessor() {
	        setResponseQueue(Server.getResponseQueue());	        
	        logger=new Logger(this.getName());
	 }

	    public TestProcessor(Queue requestQueue, Queue responseQueue) {
	        setRequestQueue(requestQueue);
	        setResponseQueue(responseQueue);
	        logger=new Logger(this.getName());
	       
	    }
	    
	    public void run() {
	    		        
	        while (Server.isRunning()) {
	            try {
	                // Block until have info in queue	                
	            	SMSRequest smsRequest = (SMSRequest)getRequestQueue().dequeue();
	                ///////////////////////////////////////////
	                processRequest(smsRequest);
	                sleep(1);
	                ////////////////////////////////////
	           
	             } catch (Exception ex) {
	                 logger.log("run: " + ex.getMessage());
	                 ex.printStackTrace();
	            }
	        }
	    }
	    public void processRequest(SMSRequest request){
	    	
	    		try {
	    			SMSResponse response=(SMSResponse)request.getResponse();
	    	    	//response.setInfo("Test ");
	    	    	if(response!=null)
	    	    	getResponseQueue().enqueue(response);
				} catch (Exception e) {
					// TODO: handle exception
					e.printStackTrace();
				}  	
	    	
	    	
	    }
	    
	    public static void main (String args[]){
	    	
	    	TestProcessor sonph=new TestProcessor();
	    	sonph.run();
	    	
	    	
	    }
	    
	   
}
